package com.gitee.wsl.struct.router

/**
 * HTTP Request methods, with the ability to decode a `String` back
 * to its enum value.
 */
enum class Method {
    GET, PUT, POST, DELETE, HEAD,
    OPTIONS, TRACE, CONNECT, PATCH, PROPFIND,
    PROPPATCH, MKCOL, MOVE, COPY, LOCK,
    UNLOCK, NOTIFY, SUBSCRIBE, ALL;

    companion object {
        fun lookup(method: String): Method? {
            return try {
                valueOf(method)
            } catch (e: IllegalArgumentException) {
                // TODO: Log it?
                null
            }
        }
    }
}